var express = require('express');
var router = express.Router();
// 引入封装好的db/sql.js文件
var sql = require('../db/sql');

/* GET home page. */
router.get('/', function(req, res, next) {
  // console.log(sql);
  var aaa = req.query.callback;

  sql('select * from user')
  .then(data=>{
    // console.log(data);
    // res.send(data)
    data = JSON.stringify(data);
    res.send(`${aaa}(${data})`)
  }).catch(err=>{
    console.log(err);
  })
  //res.render('index', { title: 'Express' });
});

module.exports = router;
